package cn.seqdata.jpa.converter;

import javax.persistence.AttributeConverter;

import org.joda.time.Period;

public class PeriodConverter implements AttributeConverter<Period, String> {
	public static final PeriodConverter instance = new PeriodConverter();

	@Override
	public String convertToDatabaseColumn(Period attribute) {
		return null != attribute ? attribute.toString() : null;
	}

	@Override
	public Period convertToEntityAttribute(String dbData) {
		return null != dbData ? Period.parse(dbData) : null;
	}
}
